<template>
	<view>
		<u-toast ref="uToast"></u-toast>
		<u-navbar :placeholder="true" @leftClick="goBack" title="选择订单"></u-navbar>
		<view class="padding-bottom-xl">
			<view v-for="(item,index) in orderlist" :key="index" class="margin-sm padding-sm radius bg-white ">
				<view class="flex align-center justify-between">
					<view>{{item.StoreInfo.StoreName}}</view>
					<view>{{item.StateTag}}</view>
				</view>
				<u-line dashed margin="20rpx 0px 20rpx 0"></u-line>
				<view>
					<view class="text-lg text-bold">{{item.RoomInfo.Name}}</view>
					<view class="text-sm margin-top-sm">开始时间：{{item.StartTime}}</view>
					<view class="text-sm margin-top-xs">结束时间：{{item.EndTime}}</view>
				</view>
				<u-line dashed margin="20rpx 0px 20rpx 0"></u-line>
				<view class="flex justify-end">
					<button class="cu-btn sm bg-blue" @click="changeOpenDoor(0,item)">开大门</button>
					<button class="cu-btn sm bg-blue margin-left-xs" @click="changeOpenDoor(-1,item)">开玻璃门</button>
					<button class="cu-btn sm bg-tea margin-left-xs" @click="changeOpenDoor(1,item)">开室内门</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderlist: [],
				current: -1,
			}
		},
		onLoad() {
			this.orderlist = uni.getStorageSync('OrderList');
			//uni.clearStorageSync();
			console.log(this.orderlist)
		},
		methods: {
			changeOpenDoor(e, item) {
				//e 0开大门  1开室内门
				this.showOpenDoorModal = false;
				uni.showLoading({
					title: '开锁中，请稍后'
				});
				uni.$u.http.post('/Customer/OpenDoor', {
					orderId: item.Id,
					index: e
				}).then(res => {
					//完成后再次查询门锁状态，
					this.$refs.uToast.show({
						message: res.msg
					})
				});
			},
			goBack() {
				uni.navigateBack();
			},
		}
	}
</script>

<style>
</style>
